<?php

class SkillsController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
         $this->_helper->layout()->setLayout('layoutextra');
    }

    public function indexAction()
    {
        // action body
    }

    public function getindicatorsAction()
    {
        $idCargo = $this->getRequest()->getParam('idcargo');
        $numId = $this->getRequest()->getParam('numId');
        // consulta a las tablas
        $mSkills = new Model_Skills();
        
        $data['skills'] = $mSkills->getIndicators($idCargo);
        $data['numId'] = $numId;
        $data['idCargo'] = $idCargo;
        
        
        if(is_array($data)){
            $msg = 1;
            $success = true;            
        }else{
            $msg = 'Error al realizar la consulta';
            $succes = false;
            $data = array();            
        }
        $this->view->data = $data;        
    }

    public function saveskillsAction()
    {
        $numId = $this->getRequest()->getParam('numId');
        $data = $this->getRequest()->getParam('data');
        $skills = explode('&', $data);

        $mSkills = new Model_Skills();

        $proc = $mSkills->saveResults($skills, $numId);
        if($proc == 1){
            $success = true;
            $msg = 1;
        }else {
            $success = false;
            $msg = $proc;
        }        
        $response = array(
            'success' => $success,
            'msg' => $msg            
        );
        
        
        $this->_helper->json->sendJson($response);        
    }
}
?>
